package com.teamclub.app.scontrollers

import com.teamclub.base.sservices.storage.StorageService
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.{PostMapping, RequestMapping, RequestParam, RestController}
import org.springframework.web.multipart.MultipartFile

/**
  * Created by ilkkzm on 17-6-23.
  */
@RestController("com.teamclub.app.scontrollers.FileUploadController")
@RequestMapping(Array("/"))
class FileUploadController {
  val logger = LoggerFactory.getLogger(classOf[FileUploadController])

  @Autowired
  var storageService: StorageService = _


  def index() = {
    "uploadForm"
  }

  @PostMapping(Array("/app/fileupload"))
  def upload(@RequestParam("file") file: MultipartFile) = {
    logger.info("come in to upload")
    storageService.store(file)
  }
}
